/*******************************************************************************
*
*               COPYRIGHT (c) 2015-2016 Broadlink Corporation
*                         All Rights Reserved
*
* The source code contained or described herein and all documents
* related to the source code ("Material") are owned by Broadlink
* Corporation or its licensors.  Title to the Material remains
* with Broadlink Corporation or its suppliers and licensors.
*
* The Material is protected by worldwide copyright and trade secret
* laws and treaty provisions. No part of the Material may be used,
* copied, reproduced, modified, published, uploaded, posted, transmitted,
* distributed, or disclosed in any way except in accordance with the
* applicable license agreement.
*
* No license under any patent, copyright, trade secret or other
* intellectual property right is granted to or conferred upon you by
* disclosure or delivery of the Materials, either expressly, by
* implication, inducement, estoppel, except in accordance with the
* applicable license agreement.
*
* Unless otherwise agreed by Broadlink in writing, you may not remove or
* alter this notice or any other notice embedded in Materials by Broadlink
* or Broadlink's suppliers or licensors in any way.
*
*******************************************************************************/

#ifndef __DNA_FLASH_H
#define __DNA_FLASH_H

#ifdef __cplusplus
    extern "C" {
#endif

/** @defgroup dna_iflash Macro
  * @{
  */

#define DNA_FLASH_SECTOR_SIZE  0x1000                       /**< define Flash sector size: 4KiB */

/**
  * @}
  */


/**  Erase internal flash
 *
 * This will erase the flash for the specified start address
 * and size
 *
 * \param addr Start address in flash (*MUST* 4 KB alignment)
 * \param len Number of bytes to be erased (*MUST* 4 KB alignment)
 * \return DNA_SUCCESS on success
 */
int dna_flash_erase(unsigned int addr, unsigned int len);

/**  Write data to internal flash
 *
 * This will write specified number of bytes to flash.
 * Note that flash needs to be erased before writing.
 *
 * \param addr Write address in flash
 * \param buff Pointer to the data to be written
 * \param len Length of data to be written
 *
 * \return DNA_SUCCESS on success
 */
int dna_flash_write(unsigned int addr, unsigned char * buff, unsigned int len);

/**  Read data from internal flash
 *
 * This will read specified number of bytes from flash.
 *
 * \param addr Read address in flash
 * \param buff Pointer to store the read data
 * \param len Length of data to be read
 * 
 * \return DNA_SUCCESS on success
 */
int dna_flash_read(unsigned int addr, unsigned char * buff, unsigned int len);

#ifdef __cplusplus
}
#endif

#endif
